package com.wwp.tbshop.presenter;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import com.wwp.tbshop.activity.SearchToActivity;
import com.wwp.tbshop.model.bean.SearchListBean;

import retrofit2.Call;

/**
 * Created by Xiaokun on 2017/6/19.
 */

public class SearchPresenter extends BasePresenter<SearchListBean>{


    private Context mContext;

    public SearchPresenter(Context context){
        this.mContext=context;
    }

    public void searchGoods(String keyword, int page, int pageNum, String orderby){
        Call<SearchListBean> searchListBeanCall = mApiService.searchGoodsList(keyword, page, pageNum, orderby);
        searchListBeanCall.enqueue(mCallback);
    }


    @Override
    protected void onServerBug(int code) {

    }

    @Override
    protected void onConnectError(String message) {

    }

    @Override
    protected void onSuccess(SearchListBean searchListBean) {
        Log.e("search", "setProductList:"+searchListBean.getResponse());
        if (searchListBean!=null){
            ((SearchToActivity) mContext).setProductList(searchListBean.getProductList());
        }
    }
}
